# 读取文件函数
def read_file(path_file,mode):
    with open(path_file, mode, encoding='utf8') as f:
        result = f.read()
    return result

# commot = read_file('news.txt', 'r')
# print(commot)

# 可变参数：不定长位置参数和不定长关键字参数
# 注意：不管是形参还是实参，关键字参数都要放在位置参数后边，否则报错
def funname(*args, **kwargs):
    print(args)
    print(kwargs)

# result = funname(1,2,3,45,a=1, b=2)
# print(result)

# 默认参数，又叫缺省参数
# 注意：缺省参数 必须 放在位置参数的后边，否则报错
def print_info(name, title='', gender=True):
    gender_text = '男性'
    if not gender:
        gender_text = '女性'
    print(f"{name} {title} 是 {gender_text}")

# result = print_info('二两', '运营', False)

# 高阶函数，将函数作为函数的参数
def add(a, b):
    return a + b

f = add

def new_add(a, b, f):
    return f(a, b) + f(a, b)

result = new_add(1,2,f)
print(result)


